package ua.kpi.fpm.km61.strat.sp.la;

public class ResString extends MarkedString  implements Comparable <ResString>{

    protected String lex;

    public ResString() {
    }

    /**
     * @return the lex
     */
    public String getLex() {
        return lex;
    }
    
    /**
     * @return the code
     */
    public int getCode() {
        return (str.length() >= 3 )? str.substring(0, 2).hashCode() : str.hashCode();
    }

    /**
     * @param lex the lex to set
     */
    public void setLex(String lex) {
        this.lex = lex;
    }

    /* (non-Javadoc)
     * @see java.lang.Object#toString()
     */
    @Override
    public String toString() {
        int h = this.getCode();
	return "[" + lex + " (" + strnum + ":" + colnum + ") val= \"" + str + "\" #= " + h + "]";
    }

    @Override
    public int compareTo(ResString arg0) {
	int res = Integer.signum(this.strnum - arg0.strnum);
	if (res == 0){
	    res = Integer.signum(this.colnum - arg0.colnum);
	}
	return res;
    }
    
    
}
